from common.connect_db import MyDB


class DataBaseThirdAd:
    """
    三方广告
    """

    @staticmethod
    def filter_life_investment_phases_by_phase_id(phase_id_list):
        """
        获得准备分红的订单信息
        :param phase_id_list:
        :return:

        """
        my_db = MyDB()
        t = str(phase_id_list).replace("[", '(').replace("]", ')')
        sql = "select * from life_investment_phases " \
              "where id in %s " % t
        result = my_db.execute_select('third', sql)
        if len(result) > 0:
            return result
        else:
            raise ValueError("没有相关订单！")

    @staticmethod
    def get_create_open_ad(ad_name):
        """
        :param ad_name:
        :return:
        """
        my_db = MyDB()
        sql = "select * from life_third_open_advertising where name = '%s' " % ad_name
        result = my_db.execute_select('thirdad', sql)
        if len(result) == 1:
            return result[0]
        else:
            raise ValueError("广告数量不正确")
